home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: hearst.acc.Virginia.EDU!murdoch!usenet
- From: brr7q@virginia.edu
- Subject: Help needed - fgets and EOF
- X-Nntp-Posting-Host: slip-25-4.itc.virginia.edu
- Message-ID: <Do2y8w.K8v@murdoch.acc.Virginia.EDU>
- Sender: usenet@murdoch.acc.Virginia.EDU
- Reply-To: brr7q@virginia.edu
- Organization: University of Virginia
- X-Newsreader: IBM NewsReader/2 v1.09
- Date: Mon, 11 Mar 1996 01:46:08 GMT
-
- Hi
-
- I wrote what I thought would be a simple application (DOS). It reads lines
- from a file character by character using fgets. I check each character
- for and newline (\n) and EOF. The program works as long as the file
- has lf at the end of the last record, BUT, if the last record does not
- end with a <lf> then the program bombs. When debugging my code I
- find that the last character read in is hex ff (255 ascii). I trap this to signal
- the end of the process, but the program still bombs. It doesn't bomb
- untill it closes all the files and is just ready to exit the program.
-
- What I need to know is what is causing this bomb. The situation arises when a
- data file has been edited but the last line does not end with a lf.
-
- Thanks for the help
-
- Brian (brr7q@virginia.edu)
-